package com.client.mapper;

import com.Emplyment.entity.Article;
import com.Emplyment.entity.CompanyCollect;
import com.Emplyment.vo.CategoriesVo;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CompanyMapper {


    @Select("SELECT * FROM article")
    List<Article> getCompany();

    @Insert("insert into company_collect(companyId, username) values (#{companyId}, #{username} )")
    void collect(CompanyCollect collect);

    @Delete("delete from company_collect where companyId = #{companyId} and username = #{username}")
    void canceCollect(CompanyCollect collect);

    @Select("SELECT COUNT(*) FROM company_collect WHERE companyId = #{companyId} and username = #{username}")
    Integer getCompanyStatus(CompanyCollect collect);

    @Update("UPDATE article SET collect_number = collect_number + 1 WHERE id = #{companyId}")
    void updateCollectCount(Integer companyId);

    @Update("UPDATE article SET collect_number = collect_number - 1 WHERE id = #{companyId}")
    void updateCancelCollectCount(Integer companyId);

    @Select("SELECT id,categoryName,categoryAlias FROM category")
    List<CategoriesVo> getCategories();

    @Select("SELECT * FROM article WHERE categoryId = #{categoryId}")
    List<Article> ByCategoryIdCompany(Integer categoryId);
}
